﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using TimeSnapperPluginAPI;

namespace GCalPlugin
{
    public class CreateTaskMenuItem : TimeSnapperMenuItem
    {
        private IServices services;

        public event EventHandler<CreateTaskEventArgs> CreateTask;

        public CreateTaskMenuItem(TimeSnapperMenu belongsTo, string text) : base(belongsTo, text)
        {
            this.services = services;
        }
        public override void Click(object sender, EventArgs e)
        {
            TimeBarContextEventArgs args = (TimeBarContextEventArgs)e;
            if (args.TimeBarState.SelectedItems.Count == 0) return;

            //args.TimeBarState.SelectedDate;
            var start = args.TimeBarState.SelectedItems.First();
            var end = args.TimeBarState.SelectedItems.Last();

            if(CreateTask != null)
            {
                CreateTask(this,new CreateTaskEventArgs(){start = start,end = end});
            }
            Debug.WriteLine(string.Format("from: {0} to: {1}",start.ActivityId,end.ActivityId));
        }
    }

    public class CreateTaskEventArgs : EventArgs
    {
        public Activity start { get; set; }
        public Activity end { get; set; }
    }
}
